package com.lingchen.boot.utils;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

/**
 * I'm a cute code dog
 * User: LingChen
 * Date:2017/11/6
 * Time:10:30
 */
public class CommonUtil {
    public static byte[] readStream(InputStream inStream) throws Exception{
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = -1;
        while((len = inStream.read(buffer)) != -1){
            outStream.write(buffer, 0, len);
        }
        outStream.close();
        inStream.close();
        return outStream.toByteArray();
    }
}
